<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md15">
                    <div class="layui-row layui-col-space15">
                        <div class="layui-col-md12">
                            <div class="layui-card">
                                <div class="layui-card-header">单个用户启动列表-条件筛选</div>
                                <form class="layui-row layui-form " style="display: flex;flex-direction: row;margin-top: 10px" action="">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">查询对象</label>
                                        <div class="layui-input-block " id="audio">
                                            <input name="people" title="教师" type="radio" lay-filter="people" checked="" value="t">
                                        </div>
                                    </div>
                                    <div class="layui-form-item layui-col-md8" >
                                        <label class="layui-form-label">设备ID</label>
                                        <div class="layui-input-block">
                                            <input name="deviceId" id="deviceId" class="layui-input" type="text" placeholder="请输入设备ID" autocomplete="off" lay-verify="deviceId">
                                        </div>
                                    </div>
                                    &nbsp;&nbsp;<a class="layui-btn" id="search"><i class="layui-icon layui-icon-search">&#xe615;</i></a>
                                </form>
                                <div class="layui-card-body">
                                    <table id="startUp" lay-filter="startUp"></table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="js/echarts.min.js"></script>
<script>
    var startInter = api.inter;
    var audio = "t", deviceId="" ;//初始化查询身份为教师,与当前的时间
    var arrTitle=[];//标题
    $(document).ready(function () {
        $("#search").click(function () {
            getStartUp();
        });

        layui.use(['form', 'table', 'laydate'], function () {
            var form = layui.form
                , layer = layui.layer
                , laydate = layui.laydate;


            //监听单选框的值
            form.on("radio(people)", function (data) {
                var idCard = data.value;
                audio = idCard;
                getStartUp(idCard);

            });


            $("#deviceId").bind('input propertychange', function () {
                deviceId=$("#deviceId").val();
                getStartUp();
            });
            form.render();


        });


    });

    //获取启动次数的数据
    function getStartUp() {
        layui.use('table', function () {
            var table = layui.table;
            //第一个实例
            table.render({
                elem: '#startUp'
                , url:startInter //数据接口
                ,title: '教师列表数据'
                , page: true //开启分页
                , toolbar: true
                , method: 'post'
                ,totalRow: true
                , limit : 20
                , limits: [20, 40, 60, 100]
                , where: {
                    type:audio,
                    device:deviceId,
                    action: "userStat",
                }
                , cols: [[ //表头
                    {field: 'index', title: '序号', fixed: 'left', type: 'numbers',toolbar: "#tableId"}
                    ,{field: 'IP', title: '启动IP', width: 150}
                    , {field: 'isFirst', title: '是否首次启动', width: 150,toolbar:"#isStratUp" }
                    , {field: 'startTime', title: '启动时间',toolbar:"#appTime"}
                    , {field: 'country', title: '国家'}
                    , {field: 'city', title: '城市'}
                ]]
                , done: function (res, curr, count) {
                    var that = this.elem.next();
                    res.data.forEach(function (item, index) {


                        if(item.yid){
                        }
                        else {
                            var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']").css({"background-color": "#F0F0F0"});
                        }
                    });
                    if (res.count == 0) {
                        layer.msg("没有符合条件的数据哦");
                    }
                }

            });



        });

    }





</script>

<!--//是否首次启动-->
<script type="text/html" id="isStratUp">
    {{#  if(d.isFirst =="0"){ }}

    <a style="color: green" class="layui-table-link">否</a>

    {{#  } }}
    {{#  if(d.isFirst =="1"){ }}


    <a style="color: green" class="layui-table-link">是</a>
    {{#  } }}

</script>
<!--//APP启动的时间装换-->
<script type="text/html" id="appTime">
    <a  class="layui-table-link">{{to_date(d.startTime)}}</a>
</script>
<!--//来自服务器的启动的时间装换-->
<script type="text/html" id="serverTime">
    <a  class="layui-table-link">{{to_date(d.uptime)}}</a>
</script>
